/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-05-30
 * 21:09
 */
public class Test {
    public static int countSegments(String s) {
        int len=s.length();
        if(len==0){
            return 0;
        }
        String[] strings=s.split(" ");
        int count =0;
        for (int i = 0; i <strings.length; i++) {

            if(strings[i]!=""){
                count++;
            }
        }
        return count;
    }
    public static void main(String[] args) {
       int count= countSegments("he ren liang:    zui zhong 会成功");
        System.out.println(count);

    }
}
